package com.itheima.util;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Random;

/*
专门负责 随机生成各种
 */
public class RandomUtil {
    private static Random r = new Random();
    private static ArrayList<String> danXinglist = null;
    private static ArrayList<String> fuXinglist = null;
    private static ArrayList<String> mingList = null;
    private static StringBuilder allZi=new StringBuilder();
    static {
        danXinglist = NameUtil.danXing();
        fuXinglist = NameUtil.fuXing();
        mingList = NameUtil.getZi();
        for (char i = 'A'; i <='Z' ; i++) {
            allZi.append(i);
        }
        for (char i = 'a'; i <='z' ; i++) {
            allZi.append(i);
        }
        for (char i = '0'; i <='9' ; i++) {
            allZi.append(i);
        }
    }

    static {
        int a = 10;
    }

    private RandomUtil() {

    }

    //生成姓
    public static String getXing() {
        int i = r.nextInt(10);
        if (i == 0) {
            return fuXinglist.get(r.nextInt(fuXinglist.size()));
        }
        return danXinglist.get(r.nextInt(danXinglist.size()));
    }

    //生成名
    public static String getMing() {
        int i = r.nextInt(2);
        if (i == 0) {
            return mingList.get(r.nextInt(mingList.size()));
        }
        return mingList.get(r.nextInt(mingList.size())) + mingList.get(r.nextInt(mingList.size()));
    }

    public static String getGender() {
        int i = r.nextInt(2);
        if (i == 0) {
            return "男";
        }
        return "女";
    }
    public static LocalDate getBirthday() {
        LocalDate sheng = LocalDate.of(1995, 1, 1);
        LocalDate localDate = sheng.plusYears(r.nextInt(11)).plusMonths(r.nextInt(13)).plusDays(r.nextInt(31));
        return localDate;

    }
    public static String getPhone() {
        StringBuilder sb= new StringBuilder("1");
        for (int i = 0; i < 10; i++) {
            sb.append(r.nextInt(10));
        }
        return sb.toString();

    }
    public static ArrayList<String> getWxs() {
        ArrayList<String> list = new ArrayList<>();
        int number = r.nextInt(2);
        if (number==0){
            list.add(getWXNumber());
            return list;
        }
        list.add(getWXNumber());
        list.add(getWXNumber());
       return list;

    }

    private static String getWXNumber() {
        StringBuilder sb = new StringBuilder();
        int leng = r.nextInt(11)+10;
        for (int i = 0; i < leng; i++) {
            sb.append(allZi.charAt(r.nextInt(allZi.length())));
        }
        return sb.toString();
    }
}
